import React from 'react'
import msgHandleRoute from "./index"
import { fromJS } from 'immutable'

const MsgReducer = (prevState = {...msgHandleRoute.state}, action) => {
    let currentState = (fromJS(prevState)).toJS();

    //循环获取要操作的type
    for(let key in msgHandleRoute.actionNames) {
        if(msgHandleRoute.actionNames[key] === action.type) {
            msgHandleRoute.actions[msgHandleRoute.actionNames[key]](currentState, action)
            break;
        }
    }

    return currentState;
}

export default MsgReducer;